package com.example.mapper;

import com.example.pojo.Task;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface TaskMapper {
    @Insert("insert into productionTasks (taskName,planID,managerID,status,startDate,endDate) values (#{taskName},#{planID},#{managerID},#{status},#{startDate},#{endDate})")
    void add(Task task);

    Long count(String taskName, String status, LocalDate begin, LocalDate end);

    List<Task> page(Integer start, Integer pageSize, String taskName, String status, LocalDate begin, LocalDate end);
@Update("update productionTasks set status=#{status} where taskID = #{taskID}")
    void update(Task task);
@Select("select * from productionTasks")
    List<Task> selectAll();
    @Update("update productionTasks set schedulingMode=#{schedulingMode},priorityRules=#{priorityRules},bufferTime=#{bufferTime} where taskID = #{taskID}")
    void updates(Task task);

    Long counts(String taskName, String status, String schedulingMode, String priorityRules, LocalDate begin, LocalDate end);

    List<Task> pages(Integer start, Integer pageSize, String taskName, String status, String schedulingMode, String priorityRules, LocalDate begin, LocalDate end);

    @Select("select count(*) from productionTasks where planID=#{planID}")
    int selectno(int planID);
    @Select("select count(*) from productionTasks where planID=#{planID} and status='已完成'")
    int selectyy(int planID);
@Select("select * from productionTasks where taskID=#{taskID}")
    Task selectone(int taskID);
}
